package com.ruoyi.system.service.impl;

import java.util.List;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CrmUserMapper;
import com.ruoyi.system.domain.CrmUser;
import com.ruoyi.system.service.ICrmUserService;

/**
 * CRM基础用户Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@Service
public class CrmUserServiceImpl implements ICrmUserService 
{
    @Autowired
    private CrmUserMapper crmUserMapper;

    /**
     * 查询CRM基础用户
     * 
     * @param id CRM基础用户主键
     * @return CRM基础用户
     */
    @Override
    public CrmUser selectCrmUserById(String id)
    {
        return crmUserMapper.selectCrmUserById(id);
    }

    /**
     * 查询CRM基础用户列表
     * 
     * @param crmUser CRM基础用户
     * @return CRM基础用户
     */
    @Override
    public List<CrmUser> selectCrmUserList(CrmUser crmUser)
    {
        return crmUserMapper.selectCrmUserList(crmUser);
    }

    /**
     * 新增CRM基础用户
     * 
     * @param crmUser CRM基础用户
     * @return 结果
     */
    @Override
    public int insertCrmUser(CrmUser crmUser)
    {
        String password = crmUser.getPassword();
        String encryptedPassword = DigestUtils.md5Hex(password);
        crmUser.setPassword(encryptedPassword);
        return crmUserMapper.insertCrmUser(crmUser);
    }

    /**
     * 修改CRM基础用户
     * 
     * @param crmUser CRM基础用户
     * @return 结果
     */
    @Override
    public int updateCrmUser(CrmUser crmUser)
    {
        return crmUserMapper.updateCrmUser(crmUser);
    }

    /**
     * 批量删除CRM基础用户
     * 
     * @param ids 需要删除的CRM基础用户主键
     * @return 结果
     */
    @Override
    public int deleteCrmUserByIds(String[] ids)
    {
        return crmUserMapper.deleteCrmUserByIds(ids);
    }

    /**
     * 删除CRM基础用户信息
     * 
     * @param id CRM基础用户主键
     * @return 结果
     */
    @Override
    public int deleteCrmUserById(String id)
    {
        return crmUserMapper.deleteCrmUserById(id);
    }
}
